package com.mybatis.lo.model;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

/**
 * 全局配置类
 * @author zhangbh
 * 2023-06-09 07:16
 **/
@Setter
public class Configuration {

    /**
     * 数据源对象
     */
    @Getter
    private DataSource dataSource;
    @Setter(AccessLevel.PRIVATE)
    private Map<String, MappedStatement> mappedStatements = new HashMap<>();

    public MappedStatement getMappedStatement(String statementId) {
        return mappedStatements.get(statementId);
    }

    /**
     * 增加查询关联信息
     * @param statementId ID
     * @param mappedStatement 配置信息
     * @return 全局配置对象
     */
    public Configuration addMappedStatement(String statementId, MappedStatement mappedStatement) {
        mappedStatements.put(statementId, mappedStatement);
        return this;
    }

}
